import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as bodyParser from "body-parser"
import { NestExpressApplication } from '@nestjs/platform-express';
import { ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  
  app.useGlobalPipes(new ValidationPipe);
  app.use(bodyParser.json({ limit: "50mb" }))

  //跨域
  app.enableCors({
    origin(origin, callback) {
      callback(null, origin);
    },
    credentials: true,
  })

  const options = new DocumentBuilder()
    .setTitle('阔哥牛逼')
    .setDescription('阔哥 API 文档')
    .setVersion('1.0')
    .addCookieAuth("token")
    .build()

  const document = SwaggerModule.createDocument(app, options)
  // 设置 swagger 网址
  SwaggerModule.setup('docs', app, document);

  await app.listen(14514);
}
bootstrap();
